﻿function HomeController($scope, LoginFactory, TaskFactory, $route) {

    $scope.user = {};

    $scope.login = function () {
        LoginFactory.Login($scope.user).then(function () { $route.reload(); });
    }
    $scope.logout = function () {
        LoginFactory.Logout();
    }

    $scope.CheckLogin = function() 
    {
        if (localStorage.getItem('token')) return true;
        else return false;
    }
    if (localStorage.getItem('token')) {
        TaskFactory.GetAllTasks().then(function (data) {
            $scope.tasks = data;
            console.log($scope.tasks);
        })
    }
}
HomeController.$inject = ['$scope', 'LoginFactory', 'TaskFactory', '$route'];